<template>
    <div>
        <div class="mui-numbox" data-numbox-min='1'>
            <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
            <input id="test" class="mui-input-numbox" type="number" value="1" @change="changeNum" ref="shopNum" readonly/>
            <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
        </div>
    </div>
</template>

<script>
    //导入mui组件js
    import mui from'../../lib/mui/js/mui.min.js'
    export default {
        data() {
            return {

            }
        },
        mounted(){
            mui('.mui-numbox').numbox();
        },

        methods:{
            changeNum(){
                this.$emit('getChlidNum',this.$refs.shopNum.value);
            },
        },

        props:['maxNum'],
        watch:{
            maxNum:function(newVal, oldVal){
                mui('.mui-numbox').numbox().setOption('max',parseInt(newVal));
            }
        }
    }
</script>

<style lang="less" scoped>
    .mui-numbox{
        height: 30px;     
    }
</style>
